var utils = require('../utils/util.js')

/** 获取请求凭证 */
const getAuthorization = () => {
  let userInfo = getUserInfo();
  if (utils.isInvalid(userInfo)) {
    return "";
  }
  return userInfo['miniOpenId'];
}

const removeData = (key) => {
  wx.removeStorageSync(key);
}

const saveData = (key, val) => {
  wx.setStorageSync(key, val)
}
const getData = (key) => {
  let data = wx.getStorageSync(key);
  if (utils.isInvalid(data)) {
    return "";
  }
  return data;
}
const saveUserInfo = (val) => {
  wx.setStorageSync("userInfo", val)
}
const getUserInfo = () => {
  return wx.getStorageSync("userInfo")
}


module.exports.getAuthorization = getAuthorization
module.exports.saveData = saveData
module.exports.getData = getData
module.exports.saveUserInfo = saveUserInfo
module.exports.getUserInfo = getUserInfo
module.exports.removeData = removeData
